package com.huawei.hwCloudJs.service.a;

import android.util.Log;
import com.huawei.hwCloudJs.d.f;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class d<T> {
    private static final String a = "SerializedObject";
    private String b;

    public d(String str) {
        this.b = str;
    }

    public T a() {
        Throwable th;
        T t;
        T t2 = null;
        Closeable fileInputStream;
        Closeable objectInputStream;
        try {
            fileInputStream = new FileInputStream(this.b);
            try {
                objectInputStream = new ObjectInputStream(fileInputStream);
                try {
                    t2 = objectInputStream.readObject();
                    f.a(fileInputStream);
                    f.a(objectInputStream);
                } catch (IOException e) {
                    try {
                        Log.e(a, "read file error ");
                        f.a(fileInputStream);
                        f.a(objectInputStream);
                        return t2;
                    } catch (Throwable th2) {
                        th = th2;
                        f.a(fileInputStream);
                        f.a(objectInputStream);
                        throw th;
                    }
                } catch (Exception e2) {
                    Log.e(a, "read file error ");
                    f.a(fileInputStream);
                    f.a(objectInputStream);
                    return t2;
                }
            } catch (IOException e3) {
                t = t2;
                Log.e(a, "read file error ");
                f.a(fileInputStream);
                f.a(objectInputStream);
                return t2;
            } catch (Exception e4) {
                t = t2;
                Log.e(a, "read file error ");
                f.a(fileInputStream);
                f.a(objectInputStream);
                return t2;
            } catch (Throwable th3) {
                Throwable th4 = th3;
                t = t2;
                th = th4;
                f.a(fileInputStream);
                f.a(objectInputStream);
                throw th;
            }
        } catch (IOException e5) {
            fileInputStream = t2;
            objectInputStream = t2;
            Log.e(a, "read file error ");
            f.a(fileInputStream);
            f.a(objectInputStream);
            return t2;
        } catch (Exception e6) {
            fileInputStream = t2;
            objectInputStream = t2;
            Log.e(a, "read file error ");
            f.a(fileInputStream);
            f.a(objectInputStream);
            return t2;
        } catch (Throwable th5) {
            objectInputStream = t2;
            T t3 = t2;
            th = th5;
            fileInputStream = t3;
            f.a(fileInputStream);
            f.a(objectInputStream);
            throw th;
        }
        return t2;
    }

    public boolean a(T t) {
        Closeable fileOutputStream;
        Throwable th;
        Closeable closeable = null;
        try {
            fileOutputStream = new FileOutputStream(this.b);
            try {
                Closeable objectOutputStream = new ObjectOutputStream(fileOutputStream);
                try {
                    objectOutputStream.writeObject(t);
                    f.a(fileOutputStream);
                    f.a(objectOutputStream);
                    return true;
                } catch (IOException e) {
                    closeable = objectOutputStream;
                    try {
                        Log.e(a, "read file error ");
                        f.a(fileOutputStream);
                        f.a(closeable);
                        return false;
                    } catch (Throwable th2) {
                        th = th2;
                        f.a(fileOutputStream);
                        f.a(closeable);
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    closeable = objectOutputStream;
                    f.a(fileOutputStream);
                    f.a(closeable);
                    throw th;
                }
            } catch (IOException e2) {
                Log.e(a, "read file error ");
                f.a(fileOutputStream);
                f.a(closeable);
                return false;
            }
        } catch (IOException e3) {
            fileOutputStream = null;
            Log.e(a, "read file error ");
            f.a(fileOutputStream);
            f.a(closeable);
            return false;
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = null;
            f.a(fileOutputStream);
            f.a(closeable);
            throw th;
        }
    }

    public long b() {
        return new File(this.b).lastModified();
    }
}
